package cn.com.elite;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import sfmi.component.chnchannel.chncallcenter.client.ContractClient;
import sfmi.component.chnchannel.chncallcenter.client.CustomerClient;
import sfmi.component.chnchannel.chncallcenter.client.VOCClient;
import sfmi.component.chnchannel.chncallcenter.dto.contract.Contract;
import sfmi.component.chnchannel.chncallcenter.dto.contract.key.ContractSearchKey;
import sfmi.component.chnchannel.chncallcenter.dto.customer.Customer;
import sfmi.component.chnchannel.chncallcenter.dto.enums.ConnectMode;
import sfmi.component.chnchannel.chncallcenter.dto.voc.VOCHistory;
import sfmi.component.chnchannel.chncallcenter.exception.ChnChannelException;
//import sfmi.component.chncommon.bdt.salesorgan.GcmClerk;
import sfmi.component.chnclaim.agentforlegacyclaim.deploy.AgentForLegacyClaimHome;
import sfmi.component.chnclaim.agentforlegacyclaim.deploy.AgentForLegacyClaimRemote;
import sfmi.component.chnclaim.agentforlegacyclaim.dto.CallCenterResult;
import sfmi.component.chnclaim.agentforlegacyclaim.dto.HomepageResult;
import sfmi.component.chncommon.chnsalesorganmanager.deploy.GlobalSalesOrganServiceHome;
import sfmi.component.chncommon.chnsalesorganmanager.deploy.GlobalSalesOrganServiceRemote;

public class TestEjb {
    public static void main(String [ ] args) {
        TestEjb test = new TestEjb();   
        try {
            test.testEjb3();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    public void testEjb3() throws Exception{
//    	String ptyId="C0000051059";
//    	String ptyCls="2";
//    	String customerName="姜华";
//    	String customerTypeId="1";
//
//    	String customerId="310115198010014924";
//    	String provinceId="C01";
//    	String address="test";
//    	String zipcode="000000";
//    	String cityId="testtest";
//    	String tel="1234567890123456";
//    	String companyName="";
//    	String companyProvinceId="C01";
//    	String companyAddress="test";
//    	String companyZipcode="333333";
//    	String companyCityId="testtest";
//
//    	String companyTel="1234567890123456";
//    	String mobile="1234567890123456";
//    	String fax="05105200591";
//    	String email="test@email.com";
//    	String gender="1";
//    	String birthday="1990-1-4";
//    	String position="01";
//    	String inputClerk="1";
    		
    	CustomerClient commonClient=new CustomerClient(ConnectMode.RealServer);   
    	Customer customer=new Customer();   	
    	customer.setPtyId("C0000051059");
    	customer.setPtyCls("1");
    	customer.setCustomerName("姜华");
    	customer.setCustomerTypeId("01");
    	customer.setCustomerId("310115198010014924");
    	customer.setProvinceId("");
    	customer.setAddress("上海");
    	customer.setZipcode("222222");
    	customer.setCityId("");
    	customer.setTel("");
    	customer.setCompanyName("");
    	customer.setCompanyProvinceId("");
    	customer.setCompanyAddress("上海上海上海上海上海");
    	customer.setCompanyZipcode("");
    	customer.setCompanyCityId("");
    	customer.setCompanyTel("");
    	customer.setMobile("1234567890");
    	customer.setFax("123456");
    	customer.setEmail("testtest@samsung.com");
    	customer.setGender("2");
    	customer.setBirthday("19890104");
    	customer.setPosition("");
    	customer.setInputClerk("1");
    	Customer customer1=commonClient.updateCustomer(customer);
    	System.out.println("customer1.getBirthday():"+customer1.getBirthday());
    	
        String ptyId="C0000051059";
    	String t3url="t3://109.101.108.51:33001";
		java.util.Properties p=new java.util.Properties();
		p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
		p.put(Context.PROVIDER_URL,t3url);
		Context ctx=new InitialContext(p);
		Object h=ctx.lookup("ejb/AgentForLegacyClaim");
		AgentForLegacyClaimHome home=(AgentForLegacyClaimHome)PortableRemoteObject.narrow(h,AgentForLegacyClaimHome.class);
		AgentForLegacyClaimRemote AgentForLegacyClaimRemote=home.create();
		List<CallCenterResult> result=AgentForLegacyClaimRemote.getClaimInfoForCallCenterByPtyId(ptyId);
		if(result==null){
			System.out.println("<BR>=====null=====<BR>");
		}else{
			Iterator iterator=result.iterator();
			while(iterator.hasNext()){
				CallCenterResult callCenterResult=(CallCenterResult)iterator.next();
				System.out.println( "<BR>====================================================" );
				System.out.println( "<BR>callCenterResult.getAcceptanceNo() : " + callCenterResult.getAcceptanceNo() );
				System.out.println( "<BR>callCenterResult.getClaimNo() : " + callCenterResult.getClaimNo() );
				System.out.println( "<BR>callCenterResult.getPlcyNo() : " + callCenterResult.getPlcyNo() );
				System.out.println( "<BR>callCenterResult.getPolicyholderName() : " + callCenterResult.getPolicyholderName() );
				System.out.println( "<BR>callCenterResult.getInsuredName() : " + callCenterResult.getInsuredName() );
				System.out.println( "<BR>callCenterResult.getProductName() : " + callCenterResult.getProductName() );
				System.out.println( "<BR>callCenterResult.getDateOfLoss() : " + callCenterResult.getDateOfLoss() );
				System.out.println( "<BR>callCenterResult.getLossDescription() : " + callCenterResult.getLossDescription() );
				System.out.println( "<BR>callCenterResult.getAcceptanceStaffName() : " + callCenterResult.getAcceptanceStaffName() );
				System.out.println( "<BR>callCenterResult.getAdjusterName() : " + callCenterResult.getAdjusterName() );
				System.out.println( "<BR>====================================================" );
			}
		}
    	
    	
    }
    public void testEjb1() throws Exception{
        VOCClient vocClient=new VOCClient(ConnectMode.RealServer);  
        List<VOCHistory> list=null;
        String caprRecgNo="310115198010014924";//CallCenter Setting Value 
        try {
        	list=vocClient.findHistoryList(caprRecgNo);
        	if(list!=null&&list.size()>0){
        		for(int i=0;i<list.size();i++){
        			VOCHistory vOCHistory=(VOCHistory)list.get(i);
            		System.out.println("-------------------"+i+"------------------------");
            		System.out.println("vOCHistory:"+vOCHistory.getCaprRecgName());
            		System.out.println("vOCHistory:"+vOCHistory.getCaprRecgNo());
            		System.out.println("vOCHistory:"+vOCHistory.getCaprRecgNoTypeCd());
            		System.out.println("vOCHistory:"+vOCHistory.getChnlCd());
            		System.out.println("vOCHistory:"+vOCHistory.getChnlNm());
            		System.out.println("vOCHistory:"+vOCHistory.getProcStatCd());
            		System.out.println("vOCHistory:"+vOCHistory.getProcStatNm());
            		System.out.println("vOCHistory:"+vOCHistory.getRcivSeqNum());
            		System.out.println("vOCHistory:"+vOCHistory.getRelClerkNm());
            		System.out.println("vOCHistory:"+vOCHistory.getRelClerkNo());
            		System.out.println("vOCHistory:"+vOCHistory.getVocClsCd());
            		System.out.println("vOCHistory:"+vOCHistory.getVocClsNm());
            		System.out.println("vOCHistory:"+vOCHistory.getVocConts());
            		System.out.println("vOCHistory:"+vOCHistory.getVocTitle());
            		System.out.println("-------------------------------------------------------");
        		}
        	}
        }catch (Exception e) {
            e.printStackTrace();
        } 
    }
    public void testEjb2()throws Exception{
		String t3url = "t3://109.101.108.51:33001";
		java.util.Properties p = new java.util.Properties();
		p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
		p.put(Context.PROVIDER_URL, t3url);
		Context ctx = new InitialContext(p);

		Object h = ctx.lookup("ejb/AgentForLegacyClaim");
		AgentForLegacyClaimHome home = (AgentForLegacyClaimHome) PortableRemoteObject.narrow(h, AgentForLegacyClaimHome.class);
		AgentForLegacyClaimRemote AgentForLegacyClaimRemote = home.create();

		List<CallCenterResult> result = AgentForLegacyClaimRemote.getClaimInfoForCallCenter("653130197702113165");

		if( result == null )
		{
			System.out.println("<BR>=====null=====<BR>");
		}
		else
		{
			Iterator iterator = result.iterator();
			while( iterator.hasNext() )
			{
				CallCenterResult callCenterResult = (CallCenterResult) iterator.next();
				System.out.println( "<BR>====================================================" );
				System.out.println( "<BR>callCenterResult.getAcceptanceNo() : " + callCenterResult.getAcceptanceNo() );
				System.out.println( "<BR>callCenterResult.getClaimNo() : " + callCenterResult.getClaimNo() );
				System.out.println( "<BR>callCenterResult.getPlcyNo() : " + callCenterResult.getPlcyNo() );
				System.out.println( "<BR>callCenterResult.getPolicyholderName() : " + callCenterResult.getPolicyholderName() );
				System.out.println( "<BR>callCenterResult.getInsuredName() : " + callCenterResult.getInsuredName() );
				System.out.println( "<BR>callCenterResult.getProductName() : " + callCenterResult.getProductName() );
				System.out.println( "<BR>callCenterResult.getDateOfLoss() : " + callCenterResult.getDateOfLoss() );
				System.out.println( "<BR>callCenterResult.getLossDescription() : " + callCenterResult.getLossDescription() );
				System.out.println( "<BR>callCenterResult.getAcceptanceStaffName() : " + callCenterResult.getAcceptanceStaffName() );
				System.out.println( "<BR>callCenterResult.getAdjusterName() : " + callCenterResult.getAdjusterName() );
				System.out.println( "<BR>====================================================" );
			}
		}
	}
    public void testEjb() throws Exception {
//        Properties props = new Properties();
//        props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
//        props.setProperty(Context.PROVIDER_URL,"t3://42.1.152.217:31501");
//        Context ctx = new InitialContext(props);
//        GlobalSalesOrganServiceHome home = (GlobalSalesOrganServiceHome)ctx.lookup("ejb.GlobalSalesOrganService");
//        GlobalSalesOrganServiceRemote remote = home.create();
//        GcmClerk clerk=remote.findClerkInfo("1");
//        System.out.println(clerk.getClerkName());
        
        try {
        	ContractClient contractClient=new ContractClient(ConnectMode.RealServer);
        	String policyholdId = "C0000051059";    // CallCenter Setting Value
        	List<Contract> contractList=contractClient.findInsuranceList(policyholdId);
            if(contractList!=null&&contractList.size()>0){
            	for(int i=0;i<contractList.size();i++){
            		Contract contract=(Contract)contractList.get(i);
            		System.out.println("-------------------"+i+"------------------------");
            		System.out.println("contract:"+contract.getCurrency());
            		System.out.println("contract:"+contract.getInsuredNo());
            		System.out.println("contract:"+contract.getPolicyEndDate());
            		System.out.println("contract:"+contract.getPolicyNo());
            		System.out.println("contract:"+contract.getPolicyStartDate());
            		System.out.println("contract:"+contract.getPremium());
            		System.out.println("contract:"+contract.getTotalSumInsured());
            		System.out.println("contract:"+contract.getWrittenDate());
            		System.out.println("contract:"+contract.getInsured().getEmail());
            		System.out.println("contract:"+contract.getInsured().getEnglishName());
            		System.out.println("contract:"+contract.getInsured().getId());
            		System.out.println("contract:"+contract.getInsured().getMobileNo());
            		System.out.println("contract:"+contract.getInsured().getName());
            		System.out.println("contract:"+contract.getInsured().getNo());
            		System.out.println("contract:"+contract.getInsured().getPhoneNo());
            		System.out.println("contract:"+contract.getProduct().getEnglishName());
            		System.out.println("contract:"+contract.getProduct().getName());
            		
            		System.out.println("contract:"+contract.getPolicyStatus().getCode());
            		System.out.println("contract:"+contract.getPolicyStatus().getDetail());
            		System.out.println("contract:"+contract.getPolicyStatus().getEnglishName());
            		System.out.println("contract:"+contract.getPolicyStatus().getName());
            		
            		System.out.println("contract:"+contract.getPolicyholder().getEmail());
            		System.out.println("contract:"+contract.getPolicyholder().getEnglishName());
            		System.out.println("contract:"+contract.getPolicyholder().getId());
            		System.out.println("contract:"+contract.getPolicyholder().getMobileNo());
            		System.out.println("contract:"+contract.getPolicyholder().getName());
            		System.out.println("contract:"+contract.getPolicyholder().getNo());
            		
            		System.out.println("contract:"+contract.getMarketingStaff().getEmail());
            		System.out.println("contract:"+contract.getMarketingStaff().getEnglishName());
            		System.out.println("contract:"+contract.getMarketingStaff().getId());
            		System.out.println("contract:"+contract.getMarketingStaff().getMobileNo());
            		System.out.println("contract:"+contract.getMarketingStaff().getName());
            		System.out.println("contract:"+contract.getMarketingStaff().getNo());
            		System.out.println("contract:"+contract.getMarketingStaff().getPhoneNo());
            		System.out.println("-------------------------------------------------------");
            	}
            }
        }catch (ChnChannelException ex) {
            ex.getId();
            ex.getMessage();
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }
    
}